package
{
	import com.tutsplus.flash.LabelComponent;

	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	/**
	 * This is HelloWorld 2.0
	 * @author ckarnes
	 * @private
	 */
	public class HelloWorld extends Sprite
	{
		private var counter:Number = 0;
		private var label:LabelComponent;

		public function HelloWorld()
		{
			label = new LabelComponent();
			addChild(label);
			trace(stage);

			var timer:Timer = new Timer(1000, 0);
			timer.addEventListener(TimerEvent.TIMER, onTimer);
			timer.start();
		}

		/**
		 * 
		 * @param event
		 * 
		 */
		private function onTimer(event:TimerEvent):void
		{
			counter++;

			if (counter > (label.totalWords - 1))
				counter = 0;

			label.changeWords(counter);
		}
	}
}
